class ChinaMap{
    constructor(){
        console.log('实例化了');
        // this.cube=null;
        this.init();
    }

    init(){
        this.scene = new THREE.Scene();
        this.setCamera();
        this.setRenderer();
        const geometry=new THREE.BoxGeometry();
        const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 })
        this.cube = new THREE.Mesh(geometry, material)
        this.scene.add(this.cube)
        this.render()
        this.animate()
    }
    setCamera(){
        this.camera = new THREE.PerspectiveCamera(
            75,
            window.innerWidth / window.innerHeight,
            0.1,
            1000
          )
          this.camera.position.z=5;
    }
    setRenderer(){
        this.renderer = new THREE.WebGLRenderer()
      // 设置画布的大小
        this.renderer.setSize(window.innerWidth, window.innerHeight)
      //这里 其实就是canvas 画布  renderer.domElement
      document.body.appendChild(this.renderer.domElement);
    }
    render(){
        this.renderer.render(this.scene,this.camera);
    }
    animate(){
        requestAnimationFrame(this.animate.bind(this))
        this.cube.rotation.x += 0.01
        this.cube.rotation.y += 0.01
        this.render()
    }
}

